package net.lijingye.education.dao.impl;

import net.lijingye.education.dao.BaseDao;
import net.lijingye.education.dao.TokenDao;
import net.lijingye.education.entity.Token;
import net.lijingye.education.exception.DaoException;
import org.springframework.stereotype.Repository;

/**
 * Created by LijingYe on 2016/3/31.
 */
@Repository
public class TokenDaoImpl extends BaseDaoImpl<Token> implements TokenDao {
    @Override
    public Token getByAccessToken(String accessToken) throws DaoException {
        return getByQuery("WHERE accessToken= '" + accessToken + "'");
    }

    @Override
    public boolean isAccessTokenAlreadyExists(String accessToken) throws DaoException {
        return 0 < findByQuery("WHERE accessToken= '" + accessToken + "'").size();
    }
}
